<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="static/jquery-1.7.2.js"></script>
    <script src="static/jquery-3.6.0.min.js"></script>
</head>
<base href="http://localhost:8080/Web01_war/">
<body>

<script type="text/javascript">
    $(document).ready(function () {
        $('#login-form').submit(function (event) {
            event.preventDefault();
            let username = $('#username').val();
            let password = $('#password').val();
            let span=$('span');
            $.ajax({
                url:'/login',
                type:'POST',
                data:{
                    username:username,
                    password:password
                },
                success:function (data){
                    window.location.href='/home'
                },
                error:function (xhr,status,error){
                    // alert('登陆失败：'+xhr.responseText);
                    if(s)
                    span.innerHTML=xhr.responseText;
                }
            })
        })
    })
</script>
<form id="login-form">
    <span></span>
    <table>
       <tbody>
           <tr><label>账号</label><input type="text" name="username" id="username"></tr>
           <tr><label>密码</label></label><input type="password" name="password" id="password"></tr>
           <tr><input type="submit" value="登录"></tr>
       </tbody>
    </table>
</form>
</body>
</html>